import { submitDetectResult } from '@/api/return-factory'
import { ref } from 'vue'

/**
 * 检测结果提交服务
 */
export default function () {
  const submitLoading = ref(false)
  const submitForm = ref<Array<ReturnFactoryAPIRequest.DetectResultSubmit>>([])

  const submit = async (id: string) => {
    try {
      submitLoading.value = true
      const res = await submitDetectResult(submitForm.value, id)
      submitLoading.value = false
      return res.data
    } catch (error) {
      submitLoading.value = false
    }
  }

  return {
    submitForm,
    submitLoading,
    submit,
  }
}
